<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg10.php" ?>
<?php include_once "ewmysql10.php" ?>
<?php include_once "phpfn10.php" ?>
<?php include_once "artistainfo.php" ?>
<?php include_once "usuariosinfo.php" ?>
<?php include_once "obrasgridcls.php" ?>
<?php include_once "userfn10.php" ?>
<?php

//
// Page class
//

$artista_view = NULL; // Initialize page object first

class cartista_view extends cartista {

	// Page ID
	var $PageID = 'view';

	// Project ID
	var $ProjectID = "{04BABB11-908C-4D25-BABD-9F78C0B5CBAE}";

	// Table name
	var $TableName = 'artista';

	// Page object name
	var $PageObjName = 'artista_view';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		if ($this->UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;
	var $ExportPdfUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	function getWarningMessage() {
		return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
	}

	function setWarningMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
	}

	// Show message
	function ShowMessage() {
		$hidden = FALSE;
		$html = "";

		// Message
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sMessage . "</div>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$sWarningMessage = $this->getWarningMessage();
		$this->Message_Showing($sWarningMessage, "warning");
		if ($sWarningMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sWarningMessage;
			$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
			$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sSuccessMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sErrorMessage;
			$html .= "<div class=\"alert alert-error ewError\">" . $sErrorMessage . "</div>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo "<table class=\"ewStdTable\"><tr><td><div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div></td></tr></table>";
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p>" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Footer exists, display
			echo "<p>" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm;
		if ($this->UseTokenInUrl) {
			if ($objForm)
				return ($this->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($this->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;
		$GLOBALS["Page"] = &$this;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Parent constuctor
		parent::__construct();

		// Table object (artista)
		if (!isset($GLOBALS["artista"]) || get_class($GLOBALS["artista"]) == "cartista") {
			$GLOBALS["artista"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["artista"];
		}
		$KeyUrl = "";
		if (@$_GET["ArtistaId"] <> "") {
			$this->RecKey["ArtistaId"] = $_GET["ArtistaId"];
			$KeyUrl .= "&amp;ArtistaId=" . urlencode($this->RecKey["ArtistaId"]);
		}
		$this->ExportPrintUrl = $this->PageUrl() . "export=print" . $KeyUrl;
		$this->ExportHtmlUrl = $this->PageUrl() . "export=html" . $KeyUrl;
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel" . $KeyUrl;
		$this->ExportWordUrl = $this->PageUrl() . "export=word" . $KeyUrl;
		$this->ExportXmlUrl = $this->PageUrl() . "export=xml" . $KeyUrl;
		$this->ExportCsvUrl = $this->PageUrl() . "export=csv" . $KeyUrl;
		$this->ExportPdfUrl = $this->PageUrl() . "export=pdf" . $KeyUrl;

		// Table object (usuarios)
		if (!isset($GLOBALS['usuarios'])) $GLOBALS['usuarios'] = new cusuarios();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'view', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'artista', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();

		// Open connection
		if (!isset($conn)) $conn = ew_Connect();

		// Export options
		$this->ExportOptions = new cListOptions();
		$this->ExportOptions->Tag = "div";
		$this->ExportOptions->TagClassName = "ewExportOption";

		// Other options
		$this->OtherOptions['action'] = new cListOptions();
		$this->OtherOptions['action']->Tag = "div";
		$this->OtherOptions['action']->TagClassName = "ewActionOption";
		$this->OtherOptions['detail'] = new cListOptions();
		$this->OtherOptions['detail']->Tag = "div";
		$this->OtherOptions['detail']->TagClassName = "ewDetailOption";
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanView()) {
			$Security->SaveLastUrl();
			$this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission
			$this->Page_Terminate("artistalist.php");
		}
		$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up current action
		$this->ArtistaId->Visible = !$this->IsAdd() && !$this->IsCopy() && !$this->IsGridAdd();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();
		$this->Page_Redirecting($url);

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $ExportOptions; // Export options
	var $OtherOptions = array(); // Other options
	var $DisplayRecs = 1;
	var $StartRec;
	var $StopRec;
	var $TotalRecs = 0;
	var $RecRange = 10;
	var $RecCnt;
	var $RecKey = array();
	var $Recordset;

	//
	// Page main
	//
	function Page_Main() {
		global $Language;

		// Load current record
		$bLoadCurrentRecord = FALSE;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;

		// Set up Breadcrumb
		if ($this->Export == "")
			$this->SetupBreadcrumb();
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["ArtistaId"] <> "") {
				$this->ArtistaId->setQueryStringValue($_GET["ArtistaId"]);
				$this->RecKey["ArtistaId"] = $this->ArtistaId->QueryStringValue;
			} else {
				$sReturnUrl = "artistalist.php"; // Return to list
			}

			// Get action
			$this->CurrentAction = "I"; // Display form
			switch ($this->CurrentAction) {
				case "I": // Get a record to display
					if (!$this->LoadRow()) { // Load record based on key
						if ($this->getSuccessMessage() == "" && $this->getFailureMessage() == "")
							$this->setFailureMessage($Language->Phrase("NoRecord")); // Set no record message
						$sReturnUrl = "artistalist.php"; // No matching record, return to list
					}
			}
		} else {
			$sReturnUrl = "artistalist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

		// Render row
		$this->RowType = EW_ROWTYPE_VIEW;
		$this->ResetAttrs();
		$this->RenderRow();

		// Set up detail parameters
		$this->SetUpDetailParms();
	}

	// Set up other options
	function SetupOtherOptions() {
		global $Language, $Security;
		$options = &$this->OtherOptions;
		$option = &$options["action"];

		// Add
		$item = &$option->Add("add");
		$item->Body = "<a class=\"ewAction ewAdd\" href=\"" . ew_HtmlEncode($this->AddUrl) . "\">" . $Language->Phrase("ViewPageAddLink") . "</a>";
		$item->Visible = ($this->AddUrl <> "" && $Security->CanAdd());

		// Edit
		$item = &$option->Add("edit");
		$item->Body = "<a class=\"ewAction ewEdit\" href=\"" . ew_HtmlEncode($this->EditUrl) . "\">" . $Language->Phrase("ViewPageEditLink") . "</a>";
		$item->Visible = ($this->EditUrl <> "" && $Security->CanEdit());

		// Copy
		$item = &$option->Add("copy");
		$item->Body = "<a class=\"ewAction ewCopy\" href=\"" . ew_HtmlEncode($this->CopyUrl) . "\">" . $Language->Phrase("ViewPageCopyLink") . "</a>";
		$item->Visible = ($this->CopyUrl <> "" && $Security->CanAdd());

		// Delete
		$item = &$option->Add("delete");
		$item->Body = "<a class=\"ewAction ewDelete\" href=\"" . ew_HtmlEncode($this->DeleteUrl) . "\">" . $Language->Phrase("ViewPageDeleteLink") . "</a>";
		$item->Visible = ($this->DeleteUrl <> "" && $Security->CanDelete());
		$DetailTableLink = "";
		$option = &$options["detail"];

		// Detail table 'obras'
		$body = $Language->TablePhrase("obras", "TblCaption");
		$body = "<a class=\"ewAction ewDetailList\" href=\"" . ew_HtmlEncode("obraslist.php?" . EW_TABLE_SHOW_MASTER . "=artista&ArtistaId=" . strval($this->ArtistaId->CurrentValue) . "") . "\">" . $body . "</a>";
		$item = &$option->Add("detail_obras");
		$item->Body = $body;
		$item->Visible = $Security->AllowList(CurrentProjectID() . 'obras');
		if ($item->Visible) {
			if ($DetailTableLink <> "") $DetailTableLink .= ",";
			$DetailTableLink .= "obras";
		}

		// Multiple details
		if ($this->ShowMultipleDetails) {
			$body = $Language->Phrase("MultipleMasterDetails");
			$body = "<a class=\"ewAction ewDetailView\" data-action=\"view\" href=\"" . ew_HtmlEncode($this->GetViewUrl(EW_TABLE_SHOW_DETAIL . "=" . $DetailTableLink)) . "\">" . $body . "</a>";
			$item = &$option->Add("details");
			$item->Body = $body;
			$item->Visible = ($DetailTableLink <> "");

			// Hide single master/detail items
			$ar = explode(",", $DetailTableLink);
			$cnt = count($ar);
			for ($i = 0; $i < $cnt; $i++) {
				if ($item = &$option->GetItem("detail_" . $ar[$i]))
					$item->Visible = FALSE;
			}
		}

		// Set up options default
		foreach ($options as &$option) {
			$option->UseDropDownButton = FALSE;
			$option->UseButtonGroup = TRUE;
			$item = &$option->Add($option->GroupOptionName);
			$item->Body = "";
			$item->Visible = FALSE;
		}
		$options["detail"]->DropDownButtonPhrase = $Language->Phrase("ButtonDetails");
		$options["action"]->DropDownButtonPhrase = $Language->Phrase("ButtonActions");
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		if ($this->DisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->StartRec = $_GET[EW_TABLE_START_REC];
				$this->setStartRecordNumber($this->StartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$PageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($PageNo)) {
					$this->StartRec = ($PageNo-1)*$this->DisplayRecs+1;
					if ($this->StartRec <= 0) {
						$this->StartRec = 1;
					} elseif ($this->StartRec >= intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1) {
						$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1;
					}
					$this->setStartRecordNumber($this->StartRec);
				}
			}
		}
		$this->StartRec = $this->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->StartRec) || $this->StartRec == "") { // Avoid invalid start record counter
			$this->StartRec = 1; // Reset start record counter
			$this->setStartRecordNumber($this->StartRec);
		} elseif (intval($this->StartRec) > intval($this->TotalRecs)) { // Avoid starting record > total records
			$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to last page first record
			$this->setStartRecordNumber($this->StartRec);
		} elseif (($this->StartRec-1) % $this->DisplayRecs <> 0) {
			$this->StartRec = intval(($this->StartRec-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to page boundary
			$this->setStartRecordNumber($this->StartRec);
		}
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();

		// Call Row Selecting event
		$this->Row_Selecting($sFilter);

		// Load SQL based on filter
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn;
		if (!$rs || $rs->EOF) return;

		// Call Row Selected event
		$row = &$rs->fields;
		$this->Row_Selected($row);
		$this->ArtistaId->setDbValue($rs->fields('ArtistaId'));
		$this->ArtistaRubro->setDbValue($rs->fields('ArtistaRubro'));
		$this->ArtistaSubRubro->setDbValue($rs->fields('ArtistaSubRubro'));
		$this->ArtistaNombre->setDbValue($rs->fields('ArtistaNombre'));
		$this->ArtistaFoto->Upload->DbValue = $rs->fields('ArtistaFoto');
		$this->ArtistaFoto->CurrentValue = $this->ArtistaFoto->Upload->DbValue;
		$this->ArtistaBio->setDbValue($rs->fields('ArtistaBio'));
		$this->ArtistaCV->Upload->DbValue = $rs->fields('ArtistaCV');
		$this->ArtistaCV->CurrentValue = $this->ArtistaCV->Upload->DbValue;
		$this->ArtistaTel->setDbValue($rs->fields('ArtistaTel'));
		$this->ArtistaEmail->setDbValue($rs->fields('ArtistaEmail'));
		$this->ArtistaFace->setDbValue($rs->fields('ArtistaFace'));
		$this->ArtistaWeb->setDbValue($rs->fields('ArtistaWeb'));
		$this->ArtistaDireccion->setDbValue($rs->fields('ArtistaDireccion'));
		$this->ArtistaLocalidad->setDbValue($rs->fields('ArtistaLocalidad'));
		$this->ArtistaProvincia->setDbValue($rs->fields('ArtistaProvincia'));
		$this->ArtistaPais->setDbValue($rs->fields('ArtistaPais'));
		$this->ArtistaActivo->setDbValue($rs->fields('ArtistaActivo'));
	}

	// Load DbValue from recordset
	function LoadDbValues(&$rs) {
		if (!$rs || !is_array($rs) && $rs->EOF) return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->ArtistaId->DbValue = $row['ArtistaId'];
		$this->ArtistaRubro->DbValue = $row['ArtistaRubro'];
		$this->ArtistaSubRubro->DbValue = $row['ArtistaSubRubro'];
		$this->ArtistaNombre->DbValue = $row['ArtistaNombre'];
		$this->ArtistaFoto->Upload->DbValue = $row['ArtistaFoto'];
		$this->ArtistaBio->DbValue = $row['ArtistaBio'];
		$this->ArtistaCV->Upload->DbValue = $row['ArtistaCV'];
		$this->ArtistaTel->DbValue = $row['ArtistaTel'];
		$this->ArtistaEmail->DbValue = $row['ArtistaEmail'];
		$this->ArtistaFace->DbValue = $row['ArtistaFace'];
		$this->ArtistaWeb->DbValue = $row['ArtistaWeb'];
		$this->ArtistaDireccion->DbValue = $row['ArtistaDireccion'];
		$this->ArtistaLocalidad->DbValue = $row['ArtistaLocalidad'];
		$this->ArtistaProvincia->DbValue = $row['ArtistaProvincia'];
		$this->ArtistaPais->DbValue = $row['ArtistaPais'];
		$this->ArtistaActivo->DbValue = $row['ArtistaActivo'];
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language;
		global $gsLanguage;

		// Initialize URLs
		$this->AddUrl = $this->GetAddUrl();
		$this->EditUrl = $this->GetEditUrl();
		$this->CopyUrl = $this->GetCopyUrl();
		$this->DeleteUrl = $this->GetDeleteUrl();
		$this->ListUrl = $this->GetListUrl();
		$this->SetupOtherOptions();

		// Call Row_Rendering event
		$this->Row_Rendering();

		// Common render codes for all row types
		// ArtistaId
		// ArtistaRubro
		// ArtistaSubRubro
		// ArtistaNombre
		// ArtistaFoto
		// ArtistaBio
		// ArtistaCV
		// ArtistaTel
		// ArtistaEmail
		// ArtistaFace
		// ArtistaWeb
		// ArtistaDireccion
		// ArtistaLocalidad
		// ArtistaProvincia
		// ArtistaPais
		// ArtistaActivo

		if ($this->RowType == EW_ROWTYPE_VIEW) { // View row

			// ArtistaId
			$this->ArtistaId->ViewValue = $this->ArtistaId->CurrentValue;
			$this->ArtistaId->ViewCustomAttributes = "";

			// ArtistaRubro
			if (strval($this->ArtistaRubro->CurrentValue) <> "") {
				$sFilterWrk = "`RubroId`" . ew_SearchString("=", $this->ArtistaRubro->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `RubroId`, `RubroNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `rubros`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->ArtistaRubro, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->ArtistaRubro->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->ArtistaRubro->ViewValue = $this->ArtistaRubro->CurrentValue;
				}
			} else {
				$this->ArtistaRubro->ViewValue = NULL;
			}
			$this->ArtistaRubro->ViewCustomAttributes = "";

			// ArtistaSubRubro
			if (strval($this->ArtistaSubRubro->CurrentValue) <> "") {
				$sFilterWrk = "`SubRubroId`" . ew_SearchString("=", $this->ArtistaSubRubro->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `SubRubroId`, `SubRubroNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `subrubro`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->ArtistaSubRubro, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `SubRubroNombre`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->ArtistaSubRubro->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->ArtistaSubRubro->ViewValue = $this->ArtistaSubRubro->CurrentValue;
				}
			} else {
				$this->ArtistaSubRubro->ViewValue = NULL;
			}
			$this->ArtistaSubRubro->ViewCustomAttributes = "";

			// ArtistaNombre
			$this->ArtistaNombre->ViewValue = $this->ArtistaNombre->CurrentValue;
			$this->ArtistaNombre->ViewCustomAttributes = "";

			// ArtistaFoto
			if (!ew_Empty($this->ArtistaFoto->Upload->DbValue)) {
				$this->ArtistaFoto->ViewValue = $this->ArtistaFoto->Upload->DbValue;
			} else {
				$this->ArtistaFoto->ViewValue = "";
			}
			$this->ArtistaFoto->ViewCustomAttributes = "";

			// ArtistaBio
			$this->ArtistaBio->ViewValue = $this->ArtistaBio->CurrentValue;
			$this->ArtistaBio->ViewCustomAttributes = "";

			// ArtistaCV
			if (!ew_Empty($this->ArtistaCV->Upload->DbValue)) {
				$this->ArtistaCV->ViewValue = $this->ArtistaCV->Upload->DbValue;
			} else {
				$this->ArtistaCV->ViewValue = "";
			}
			$this->ArtistaCV->ViewCustomAttributes = "";

			// ArtistaTel
			$this->ArtistaTel->ViewValue = $this->ArtistaTel->CurrentValue;
			$this->ArtistaTel->ViewCustomAttributes = "";

			// ArtistaEmail
			$this->ArtistaEmail->ViewValue = $this->ArtistaEmail->CurrentValue;
			$this->ArtistaEmail->ViewCustomAttributes = "";

			// ArtistaFace
			$this->ArtistaFace->ViewValue = $this->ArtistaFace->CurrentValue;
			$this->ArtistaFace->ViewCustomAttributes = "";

			// ArtistaWeb
			$this->ArtistaWeb->ViewValue = $this->ArtistaWeb->CurrentValue;
			$this->ArtistaWeb->ViewCustomAttributes = "";

			// ArtistaDireccion
			$this->ArtistaDireccion->ViewValue = $this->ArtistaDireccion->CurrentValue;
			$this->ArtistaDireccion->ViewCustomAttributes = "";

			// ArtistaLocalidad
			$this->ArtistaLocalidad->ViewValue = $this->ArtistaLocalidad->CurrentValue;
			$this->ArtistaLocalidad->ViewCustomAttributes = "";

			// ArtistaProvincia
			$this->ArtistaProvincia->ViewValue = $this->ArtistaProvincia->CurrentValue;
			$this->ArtistaProvincia->ViewCustomAttributes = "";

			// ArtistaPais
			$this->ArtistaPais->ViewValue = $this->ArtistaPais->CurrentValue;
			$this->ArtistaPais->ViewCustomAttributes = "";

			// ArtistaActivo
			if (strval($this->ArtistaActivo->CurrentValue) <> "") {
				switch ($this->ArtistaActivo->CurrentValue) {
					case $this->ArtistaActivo->FldTagValue(1):
						$this->ArtistaActivo->ViewValue = $this->ArtistaActivo->FldTagCaption(1) <> "" ? $this->ArtistaActivo->FldTagCaption(1) : $this->ArtistaActivo->CurrentValue;
						break;
					default:
						$this->ArtistaActivo->ViewValue = $this->ArtistaActivo->CurrentValue;
				}
			} else {
				$this->ArtistaActivo->ViewValue = NULL;
			}
			$this->ArtistaActivo->ViewCustomAttributes = "";

			// ArtistaId
			$this->ArtistaId->LinkCustomAttributes = "";
			$this->ArtistaId->HrefValue = "";
			$this->ArtistaId->TooltipValue = "";

			// ArtistaRubro
			$this->ArtistaRubro->LinkCustomAttributes = "";
			$this->ArtistaRubro->HrefValue = "";
			$this->ArtistaRubro->TooltipValue = "";

			// ArtistaSubRubro
			$this->ArtistaSubRubro->LinkCustomAttributes = "";
			$this->ArtistaSubRubro->HrefValue = "";
			$this->ArtistaSubRubro->TooltipValue = "";

			// ArtistaNombre
			$this->ArtistaNombre->LinkCustomAttributes = "";
			$this->ArtistaNombre->HrefValue = "";
			$this->ArtistaNombre->TooltipValue = "";

			// ArtistaFoto
			$this->ArtistaFoto->LinkCustomAttributes = "";
			$this->ArtistaFoto->HrefValue = "";
			$this->ArtistaFoto->HrefValue2 = $this->ArtistaFoto->UploadPath . $this->ArtistaFoto->Upload->DbValue;
			$this->ArtistaFoto->TooltipValue = "";

			// ArtistaBio
			$this->ArtistaBio->LinkCustomAttributes = "";
			$this->ArtistaBio->HrefValue = "";
			$this->ArtistaBio->TooltipValue = "";

			// ArtistaCV
			$this->ArtistaCV->LinkCustomAttributes = "";
			$this->ArtistaCV->HrefValue = "";
			$this->ArtistaCV->HrefValue2 = $this->ArtistaCV->UploadPath . $this->ArtistaCV->Upload->DbValue;
			$this->ArtistaCV->TooltipValue = "";

			// ArtistaTel
			$this->ArtistaTel->LinkCustomAttributes = "";
			$this->ArtistaTel->HrefValue = "";
			$this->ArtistaTel->TooltipValue = "";

			// ArtistaEmail
			$this->ArtistaEmail->LinkCustomAttributes = "";
			$this->ArtistaEmail->HrefValue = "";
			$this->ArtistaEmail->TooltipValue = "";

			// ArtistaFace
			$this->ArtistaFace->LinkCustomAttributes = "";
			$this->ArtistaFace->HrefValue = "";
			$this->ArtistaFace->TooltipValue = "";

			// ArtistaWeb
			$this->ArtistaWeb->LinkCustomAttributes = "";
			$this->ArtistaWeb->HrefValue = "";
			$this->ArtistaWeb->TooltipValue = "";

			// ArtistaDireccion
			$this->ArtistaDireccion->LinkCustomAttributes = "";
			$this->ArtistaDireccion->HrefValue = "";
			$this->ArtistaDireccion->TooltipValue = "";

			// ArtistaLocalidad
			$this->ArtistaLocalidad->LinkCustomAttributes = "";
			$this->ArtistaLocalidad->HrefValue = "";
			$this->ArtistaLocalidad->TooltipValue = "";

			// ArtistaProvincia
			$this->ArtistaProvincia->LinkCustomAttributes = "";
			$this->ArtistaProvincia->HrefValue = "";
			$this->ArtistaProvincia->TooltipValue = "";

			// ArtistaPais
			$this->ArtistaPais->LinkCustomAttributes = "";
			$this->ArtistaPais->HrefValue = "";
			$this->ArtistaPais->TooltipValue = "";

			// ArtistaActivo
			$this->ArtistaActivo->LinkCustomAttributes = "";
			$this->ArtistaActivo->HrefValue = "";
			$this->ArtistaActivo->TooltipValue = "";
		}

		// Call Row Rendered event
		if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Set up detail parms based on QueryString
	function SetUpDetailParms() {

		// Get the keys for master table
		if (isset($_GET[EW_TABLE_SHOW_DETAIL])) {
			$sDetailTblVar = $_GET[EW_TABLE_SHOW_DETAIL];
			$this->setCurrentDetailTable($sDetailTblVar);
		} else {
			$sDetailTblVar = $this->getCurrentDetailTable();
		}
		if ($sDetailTblVar <> "") {
			$DetailTblVar = explode(",", $sDetailTblVar);
			if (in_array("obras", $DetailTblVar)) {
				if (!isset($GLOBALS["obras_grid"]))
					$GLOBALS["obras_grid"] = new cobras_grid;
				if ($GLOBALS["obras_grid"]->DetailView) {
					$GLOBALS["obras_grid"]->CurrentMode = "view";

					// Save current master table to detail table
					$GLOBALS["obras_grid"]->setCurrentMasterTable($this->TableVar);
					$GLOBALS["obras_grid"]->setStartRecordNumber(1);
					$GLOBALS["obras_grid"]->ObraArtista->FldIsDetailKey = TRUE;
					$GLOBALS["obras_grid"]->ObraArtista->CurrentValue = $this->ArtistaId->CurrentValue;
					$GLOBALS["obras_grid"]->ObraArtista->setSessionValue($GLOBALS["obras_grid"]->ObraArtista->CurrentValue);
				}
			}
		}
	}

	// Set up Breadcrumb
	function SetupBreadcrumb() {
		global $Breadcrumb, $Language;
		$Breadcrumb = new cBreadcrumb();
		$Breadcrumb->Add("list", $this->TableVar, "artistalist.php", $this->TableVar, TRUE);
		$PageId = "view";
		$Breadcrumb->Add("view", $PageId, ew_CurrentUrl());
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}
}
?>
<?php ew_Header(FALSE) ?>
<?php

// Create page object
if (!isset($artista_view)) $artista_view = new cartista_view();

// Page init
$artista_view->Page_Init();

// Page main
$artista_view->Page_Main();

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$artista_view->Page_Render();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">

// Page object
var artista_view = new ew_Page("artista_view");
artista_view.PageID = "view"; // Page ID
var EW_PAGE_ID = artista_view.PageID; // For backward compatibility

// Form object
var fartistaview = new ew_Form("fartistaview");

// Form_CustomValidate event
fartistaview.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }

// Use JavaScript validation or not
<?php if (EW_CLIENT_VALIDATE) { ?>
fartistaview.ValidateRequired = true;
<?php } else { ?>
fartistaview.ValidateRequired = false; 
<?php } ?>

// Dynamic selection lists
fartistaview.Lists["x_ArtistaRubro"] = {"LinkField":"x_RubroId","Ajax":null,"AutoFill":false,"DisplayFields":["x_RubroNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fartistaview.Lists["x_ArtistaSubRubro"] = {"LinkField":"x_SubRubroId","Ajax":null,"AutoFill":false,"DisplayFields":["x_SubRubroNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};

// Form object for search
</script>
<script type="text/javascript">

// Write your client script here, no need to add script tags.
</script>
<?php $Breadcrumb->Render(); ?>
<div class="ewViewExportOptions">
<?php $artista_view->ExportOptions->Render("body") ?>
<?php if (!$artista_view->ExportOptions->UseDropDownButton) { ?>
</div>
<div class="ewViewOtherOptions">
<?php } ?>
<?php
	foreach ($artista_view->OtherOptions as &$option)
		$option->Render("body");
?>
</div>
<?php $artista_view->ShowPageHeader(); ?>
<?php
$artista_view->ShowMessage();
?>
<form name="fartistaview" id="fartistaview" class="ewForm form-inline" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" value="artista">
<table class="ewGrid"><tr><td>
<table id="tbl_artistaview" class="table table-bordered table-striped">
<?php if ($artista->ArtistaId->Visible) { // ArtistaId ?>
	<tr id="r_ArtistaId">
		<td><span id="elh_artista_ArtistaId"><?php echo $artista->ArtistaId->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaId->CellAttributes() ?>>
<span id="el_artista_ArtistaId" class="control-group">
<span<?php echo $artista->ArtistaId->ViewAttributes() ?>>
<?php echo $artista->ArtistaId->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaRubro->Visible) { // ArtistaRubro ?>
	<tr id="r_ArtistaRubro">
		<td><span id="elh_artista_ArtistaRubro"><?php echo $artista->ArtistaRubro->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaRubro->CellAttributes() ?>>
<span id="el_artista_ArtistaRubro" class="control-group">
<span<?php echo $artista->ArtistaRubro->ViewAttributes() ?>>
<?php echo $artista->ArtistaRubro->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaSubRubro->Visible) { // ArtistaSubRubro ?>
	<tr id="r_ArtistaSubRubro">
		<td><span id="elh_artista_ArtistaSubRubro"><?php echo $artista->ArtistaSubRubro->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaSubRubro->CellAttributes() ?>>
<span id="el_artista_ArtistaSubRubro" class="control-group">
<span<?php echo $artista->ArtistaSubRubro->ViewAttributes() ?>>
<?php echo $artista->ArtistaSubRubro->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaNombre->Visible) { // ArtistaNombre ?>
	<tr id="r_ArtistaNombre">
		<td><span id="elh_artista_ArtistaNombre"><?php echo $artista->ArtistaNombre->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaNombre->CellAttributes() ?>>
<span id="el_artista_ArtistaNombre" class="control-group">
<span<?php echo $artista->ArtistaNombre->ViewAttributes() ?>>
<?php echo $artista->ArtistaNombre->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaFoto->Visible) { // ArtistaFoto ?>
	<tr id="r_ArtistaFoto">
		<td><span id="elh_artista_ArtistaFoto"><?php echo $artista->ArtistaFoto->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaFoto->CellAttributes() ?>>
<span id="el_artista_ArtistaFoto" class="control-group">
<span<?php echo $artista->ArtistaFoto->ViewAttributes() ?>>
<?php if ($artista->ArtistaFoto->LinkAttributes() <> "") { ?>
<?php if (!empty($artista->ArtistaFoto->Upload->DbValue)) { ?>
<?php echo $artista->ArtistaFoto->ViewValue ?>
<?php } elseif (!in_array($artista->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($artista->ArtistaFoto->Upload->DbValue)) { ?>
<?php echo $artista->ArtistaFoto->ViewValue ?>
<?php } elseif (!in_array($artista->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaBio->Visible) { // ArtistaBio ?>
	<tr id="r_ArtistaBio">
		<td><span id="elh_artista_ArtistaBio"><?php echo $artista->ArtistaBio->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaBio->CellAttributes() ?>>
<span id="el_artista_ArtistaBio" class="control-group">
<span<?php echo $artista->ArtistaBio->ViewAttributes() ?>>
<?php echo $artista->ArtistaBio->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaCV->Visible) { // ArtistaCV ?>
	<tr id="r_ArtistaCV">
		<td><span id="elh_artista_ArtistaCV"><?php echo $artista->ArtistaCV->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaCV->CellAttributes() ?>>
<span id="el_artista_ArtistaCV" class="control-group">
<span<?php echo $artista->ArtistaCV->ViewAttributes() ?>>
<?php if ($artista->ArtistaCV->LinkAttributes() <> "") { ?>
<?php if (!empty($artista->ArtistaCV->Upload->DbValue)) { ?>
<?php echo $artista->ArtistaCV->ViewValue ?>
<?php } elseif (!in_array($artista->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($artista->ArtistaCV->Upload->DbValue)) { ?>
<?php echo $artista->ArtistaCV->ViewValue ?>
<?php } elseif (!in_array($artista->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaTel->Visible) { // ArtistaTel ?>
	<tr id="r_ArtistaTel">
		<td><span id="elh_artista_ArtistaTel"><?php echo $artista->ArtistaTel->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaTel->CellAttributes() ?>>
<span id="el_artista_ArtistaTel" class="control-group">
<span<?php echo $artista->ArtistaTel->ViewAttributes() ?>>
<?php echo $artista->ArtistaTel->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaEmail->Visible) { // ArtistaEmail ?>
	<tr id="r_ArtistaEmail">
		<td><span id="elh_artista_ArtistaEmail"><?php echo $artista->ArtistaEmail->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaEmail->CellAttributes() ?>>
<span id="el_artista_ArtistaEmail" class="control-group">
<span<?php echo $artista->ArtistaEmail->ViewAttributes() ?>>
<?php echo $artista->ArtistaEmail->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaFace->Visible) { // ArtistaFace ?>
	<tr id="r_ArtistaFace">
		<td><span id="elh_artista_ArtistaFace"><?php echo $artista->ArtistaFace->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaFace->CellAttributes() ?>>
<span id="el_artista_ArtistaFace" class="control-group">
<span<?php echo $artista->ArtistaFace->ViewAttributes() ?>>
<?php echo $artista->ArtistaFace->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaWeb->Visible) { // ArtistaWeb ?>
	<tr id="r_ArtistaWeb">
		<td><span id="elh_artista_ArtistaWeb"><?php echo $artista->ArtistaWeb->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaWeb->CellAttributes() ?>>
<span id="el_artista_ArtistaWeb" class="control-group">
<span<?php echo $artista->ArtistaWeb->ViewAttributes() ?>>
<?php echo $artista->ArtistaWeb->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaDireccion->Visible) { // ArtistaDireccion ?>
	<tr id="r_ArtistaDireccion">
		<td><span id="elh_artista_ArtistaDireccion"><?php echo $artista->ArtistaDireccion->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaDireccion->CellAttributes() ?>>
<span id="el_artista_ArtistaDireccion" class="control-group">
<span<?php echo $artista->ArtistaDireccion->ViewAttributes() ?>>
<?php echo $artista->ArtistaDireccion->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaLocalidad->Visible) { // ArtistaLocalidad ?>
	<tr id="r_ArtistaLocalidad">
		<td><span id="elh_artista_ArtistaLocalidad"><?php echo $artista->ArtistaLocalidad->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaLocalidad->CellAttributes() ?>>
<span id="el_artista_ArtistaLocalidad" class="control-group">
<span<?php echo $artista->ArtistaLocalidad->ViewAttributes() ?>>
<?php echo $artista->ArtistaLocalidad->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaProvincia->Visible) { // ArtistaProvincia ?>
	<tr id="r_ArtistaProvincia">
		<td><span id="elh_artista_ArtistaProvincia"><?php echo $artista->ArtistaProvincia->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaProvincia->CellAttributes() ?>>
<span id="el_artista_ArtistaProvincia" class="control-group">
<span<?php echo $artista->ArtistaProvincia->ViewAttributes() ?>>
<?php echo $artista->ArtistaProvincia->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaPais->Visible) { // ArtistaPais ?>
	<tr id="r_ArtistaPais">
		<td><span id="elh_artista_ArtistaPais"><?php echo $artista->ArtistaPais->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaPais->CellAttributes() ?>>
<span id="el_artista_ArtistaPais" class="control-group">
<span<?php echo $artista->ArtistaPais->ViewAttributes() ?>>
<?php echo $artista->ArtistaPais->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
<?php if ($artista->ArtistaActivo->Visible) { // ArtistaActivo ?>
	<tr id="r_ArtistaActivo">
		<td><span id="elh_artista_ArtistaActivo"><?php echo $artista->ArtistaActivo->FldCaption() ?></span></td>
		<td<?php echo $artista->ArtistaActivo->CellAttributes() ?>>
<span id="el_artista_ArtistaActivo" class="control-group">
<span<?php echo $artista->ArtistaActivo->ViewAttributes() ?>>
<?php echo $artista->ArtistaActivo->ViewValue ?></span>
</span>
</td>
	</tr>
<?php } ?>
</table>
</td></tr></table>
<?php
	if (in_array("obras", explode(",", $artista->getCurrentDetailTable())) && $obras->DetailView) {
?>
<?php include_once "obrasgrid.php" ?>
<?php } ?>
</form>
<script type="text/javascript">
fartistaview.Init();
</script>
<?php
$artista_view->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script type="text/javascript">

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$artista_view->Page_Terminate();
?>
